{extend name='base'/}

{block name='box'}
<div class="fly-panel fly-column">
    <div class="layui-container">
        <ul class="layui-clear">
            {if condition="empty($category_id)"}
                <li class="layui-hide-xs layui-this"><a href="{{:url('Index/index')}}">首页</a></li>
            {else/}
                <li><a href="{{:url('Index/index')}}">首页</a></li>
            {/if}
            <!-- 显示所有帖子分类 -->
            {if condition="!empty($cateInfo)"}
            {foreach name="cateInfo" item="val"}
            {eq name="$val.id" value="$category_id"}
                <li class="layui-hide-xs layui-this"><a href="{{:url('Index/index',['category'=>$val.id])}}">{{$val.category_name}}</a></li>
            {else/}
                <li><a href="{{:url('Index/index',['category'=>$val.id])}}">{{$val.category_name}}</a></li>
            {/eq}

            {/foreach}
            {/if}

            <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><span class="fly-mid"></span></li>


            <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><a href="{{:url('User/userCenter',['action'=>'send'])}}">我发表的贴</a></li>
            <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><a href="{{:url('User/userCenter',['action'=>'collection'])}}">我收藏的贴</a></li>
        </ul>

        <div class="fly-column-right layui-hide-xs">
            <span class="fly-search"><i class="layui-icon"></i></span>
            <a href="{{:url('Card/newCard')}}" class="layui-btn">发表新帖</a>
        </div>
        <div class="layui-hide-sm layui-show-xs-block" style="margin-top: -10px; padding-bottom: 10px; text-align: center;">
            <a href="{{:url('Card/newCard')}}" class="layui-btn">发表新帖</a>
        </div>
    </div>
</div>

<div class="layui-container">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md8">
            <!--如果$category为no,就进入首页,显示置顶-->
            {eq name="$category" value="no"}
            <div class="fly-panel">
                <div class="fly-panel-title fly-filter">
                    <a>置顶</a>
                    <a href="#signin" class="layui-hide-sm layui-show-xs-block fly-right" id="LAY_goSignin" style="color: #FF5722;">去签到</a>
                </div>
                <ul class="fly-list">
                    {if condition="!empty($cardFirst)"}
                        {foreach name="cardFirst" item="val"}
                                <li>
                                    <!--头像-->
                                    <a href="{{:url('User/home',['id'=>$val.user_id])}}" class="fly-avatar">
                                        {if condition="empty($val.image)"}
                                        <img src="__STATIC__/head.jpg" alt="{{$val.username}}">
                                        {else/}
                                        <img src="{{:get_img_url('__STATIC__/../upload/headImg/',$val['image'],0)}}" alt="{{$val.username}}">
                                        {/if}
                                    </a>
                                    <!--帖子类型 帖子标题--->
                                    <h2>
                                        <!--帖子类型-->
                                        <a class="layui-badge">{{$val.category_name}}</a>
                                        <!--帖子标题-->
                                        <a href="{{:url('Card/cardBrowse?id='.$val.id)}}">{{$val.name}}</a>
                                    </h2>
                                    <div class="fly-list-info">
                                        <!--用户名 用户等级-->
                                        <a href="{{:url('User/home',['id'=>$val.user_id])}}" link>
                                            <!--用户名-->
                                            <cite>{{$val.username}}</cite>
                                            <!--用户等级-->
                                            <i class="layui-badge fly-badge-vip">
                                                {switch name="$val.level"}
                                                {case value="0"}普通用户{/case}
                                                {case value="1"}VIP1{/case}
                                                {case value="2"}VIP2{/case}
                                                {case value="3"}VIP3{/case}
                                                {case value="4"}VIP4{/case}
                                                {case value="5"}VIP5{/case}
                                                {/switch}
                                            </i>
                                        </a>
                                        <!--发帖时间-->
                                        <span class="time">{{$val.create_time}}</span>
                                        <!--悬赏金币-->
                                        {eq name="$val.category_id" value="1"}
                                                    <span class="fly-list-kiss layui-hide-xs" title="悬赏金币">
                                                            <!--<i class="iconfont icon-kiss"></i>-->
                                                            <i class="layui-icon" style="font-size: 18px; color: red;">&#xe65e;</i>
                                                            {{$val.gold}}</span>
                                        {/eq}
                                        <!--该提问帖是否已结-->
                                        {eq name="$val.is_end" value="2"}
                                        <span class="layui-badge fly-badge-accept layui-hide-xs">已结</span>
                                        {/eq}

                                        <!--评论数-->
                                                <span class="fly-list-nums ">
                                                    {eq name="$val.category_id" value="1"}
                                                        <i class="iconfont icon-pinglun1" title="回答"></i> {{$val.evaluate_num}}
                                                    {else/}
                                                        <i class="iconfont icon-pinglun1" title="评论"></i> {{$val.evaluate_num}}
                                                    {/eq}
                                                </span>
                                    </div>
                                    <div class="fly-list-badge">
                                        {eq name="$val.is_fine" value="1"}
                                        <span class="layui-badge layui-bg-red">精帖</span>
                                        {/eq}

                                    </div>
                                </li>
                        {/foreach}
                    {/if}




                </ul>
            </div>
            {/eq}

            <div class="fly-panel" style="margin-bottom: 0;">

                {eq name="$category" value="no"}
                <div class="fly-panel-title fly-filter">
                    {eq name="$fine" value="fine"}
                        <a href="{{:url('Index/index')}}">综合</a>
                        <span class="fly-mid"></span>
                        <a href="{{:url('Index/index',['fine'=>'fine'])}}" class="layui-this">精华</a>
                    {else/}
                        <a href="{{:url('Index/index')}}" class="layui-this">综合</a>
                        <span class="fly-mid"></span>
                        <a href="{{:url('Index/index',['fine'=>'fine'])}}">精华</a>
                    {/eq}
            <span class="fly-filter-right layui-hide-xs">
                {eq name="$action" value="byTime"}
                    <a href="{{:url('Index/index')}}" class="layui-this">按最新</a>
                    <span class="fly-mid"></span>
                    <a href="{{:url('Index/index?action=byEvaluate')}}">按热议</a>
                {else/}
                    <a href="{{:url('Index/index')}}">按最新</a>
                    <span class="fly-mid"></span>
                    <a href="{{:url('Index/index?action=byEvaluate')}}" class="layui-this">按热议</a>
                {/eq}

            </span>
                </div>
                {else/}
                <div class="fly-panel-title fly-filter">
                    {eq name="$fine" value="fine"}
                    <a href="{{:url('Index/index',['category'=>$category_id])}}">综合</a>
                    <span class="fly-mid"></span>
                    <a href="{{:url('Index/index',['fine'=>'fine','category'=>$category_id])}}" class="layui-this">精华</a>
                    {else/}
                    <a href="{{:url('Index/index',['category'=>$category_id])}}" class="layui-this">综合</a>
                    <span class="fly-mid"></span>
                    <a href="{{:url('Index/index',['fine'=>'fine','category'=>$category_id])}}">精华</a>
                    {/eq}
                    <span class="fly-filter-right layui-hide-xs">
                        {eq name="$action" value="byTime"}
                            <a href="{{:url('Index/index',['category'=>$category_id])}}" class="layui-this">按最新</a>
                            <span class="fly-mid"></span>
                            <a href="{{:url('Index/index',['action'=>'byEvaluate','category'=>$category_id])}}">按热议</a>
                        {else/}
                            <a href="{{:url('Index/index',['category'=>$category_id])}}">按最新</a>
                            <span class="fly-mid"></span>
                            <a href="{{:url('Index/index',['action'=>'byEvaluate','category'=>$category_id])}}" class="layui-this">按热议</a>
                        {/eq}

                    </span>
                </div>
                {/eq}

                <ul class="fly-list">
                    {if condition="!empty($cardList)"}
                        {foreach name="cardList" item="val"}
                        {eq name="$val.is_first" value="0"}
                            <li>
                                <!--头像-->
                                <a href="{{:url('User/home',['id'=>$val.user_id])}}" class="fly-avatar">
                                    {if condition="empty($val.image)"}
                                    <img src="__STATIC__/head.jpg" alt="{{$val.username}}">
                                    {else/}
                                    <img src="{{:get_img_url('__STATIC__/../upload/headImg/',$val['image'],0)}}" alt="{{$val.username}}">
                                    {/if}
                                </a>
                                <!--帖子类型 帖子标题--->
                                <h2>
                                    <!--帖子类型-->
                                    <a class="layui-badge">{{$val.category_name}}</a>
                                    <!--帖子标题-->
                                    <a href="{{:url('Card/cardBrowse?id='.$val.id)}}">{{$val.name}}</a>
                                </h2>
                                <div class="fly-list-info">
                                    <!--用户名 用户等级-->
                                    <a href="{{:url('User/home',['id'=>$val.user_id])}}" link>
                                        <!--用户名-->
                                        <cite>{{$val.username}}</cite>
                                        <!--用户等级-->
                                        <i class="layui-badge fly-badge-vip">
                                            {switch name="$val.level"}
                                                {case value="0"}普通用户{/case}
                                                {case value="1"}VIP1{/case}
                                                {case value="2"}VIP2{/case}
                                                {case value="3"}VIP3{/case}
                                                {case value="4"}VIP4{/case}
                                                {case value="5"}VIP5{/case}
                                            {/switch}
                                        </i>
                                    </a>
                                    <!--发帖时间-->
                                    <span class="time">{{$val.create_time}}</span>
                                    <!--悬赏金币-->
                                    {eq name="$val.category_id" value="1"}
                                        <span class="fly-list-kiss layui-hide-xs" title="悬赏金币">
                                                <!--<i class="iconfont icon-kiss"></i>-->
                                                <i class="layui-icon" style="font-size: 18px; color: red;">&#xe65e;</i>
                                                {{$val.gold}}</span>
                                    {/eq}
                                    <!--该提问帖是否已结-->
                                    {eq name="$val.is_end" value="2"}
                                        <span class="layui-badge fly-badge-accept layui-hide-xs">已结</span>
                                    {/eq}

                                    <!--评论数-->
                                    <span class="fly-list-nums ">
                                        {eq name="$val.category_id" value="1"}
                                            <i class="iconfont icon-pinglun1" title="回答"></i> {{$val.evaluate_num}}
                                        {else/}
                                            <i class="iconfont icon-pinglun1" title="评论"></i> {{$val.evaluate_num}}
                                        {/eq}
                                    </span>
                                </div>
                                <div class="fly-list-badge">
                                    {eq name="$val.is_fine" value="1"}
                                        <span class="layui-badge layui-bg-red">精帖</span>
                                    {/eq}

                                </div>
                            </li>
                        {/eq}
                        {/foreach}
                    <!--显示分页-->
                    {{$cardPage}}
                    {/if}

                </ul>
                <div style="text-align: center">
                    <div class="laypage-main">
                        <!--<a href="jie/index.html" class="laypage-next">更多求解</a>-->
                    </div>
                </div>

            </div>
        </div>
        <div class="layui-col-md4">
            <div class="fly-panel fly-signin">
                <div class="fly-panel-title">
                    签到
                    <i class="fly-mid"></i>
                    <a href="javascript:;" class="fly-link" id="qdsm">说明</a>
                    <!-- <i class="fly-mid"></i> -->
                    <!-- <a href="javascript:;" class="fly-link" id="LAY_signinTop">活跃榜 --><span class="layui-badge-dot"></span></a>
                    <span class="fly-signin-days">我的金币<cite>{{$gold_num}}</cite>个</span>
                </div>
                <div class="fly-panel-main fly-signin-main">
                    <a   class="layui-btn layui-btn-danger" id="qd">今日签到</a>
                    <span>可获得<cite>5</cite>金币</span>
<script type="text/javascript">
        $(function(){
            $("#qd").click(function(){
                //将时间转化成时间戳
                layer.msg('正在签到', {icon:16, shade: 0.1, time:0})
                // var time = Date.parse(new Date($(this).text()));
                $.ajax({
                    type: "get",
                    data: '',
                    dataType: 'json',
                    url: "{{:url('index/qd')}}",
                    success: function (data) {
                        if (data.status == 1) {
                            layer.msg('签到成功');
                        } else if(data.status == 0) {
                            layer.msg('亲,今天已经签到过啦!');
                        }else{
                            layer.msg('未知错误');

                        }
                    }
                })
                
            })

            $("#qdsm").click(function(){
                //自定页
                //捕获页
                
                    layer.msg('我是每日签到说明 ☆￣(＞。☆)', {time: 5000, icon:6});
                  

            })
        })


</script>
                    <!-- 已签到状态 -->
                    <!--
                    <button class="layui-btn layui-btn-disabled">今日已签到</button>
                    <span>获得了<cite>20</cite>飞吻</span>
                    -->
                </div>
            </div>

            <div class="fly-panel fly-rank fly-rank-reply" id="LAY_replyRank">
                <h3 class="fly-panel-title">回贴周榜</h3>
                <dl>
                    <!--<i class="layui-icon fly-loading">&#xe63d;</i>-->
                    {foreach name='timeList' item='vo'}
                    <dd>
                        <a href="{{:url('User/home',['id'=>$vo.user_id])}}">
                            <img src="{{:get_img_url('__STATIC__/../upload/headImg/',$vo['image'],0)}}"><cite>{{$vo.name}}</cite><i>{{$vo.count}}次回答</i>
                        </a>
                    </dd>
                    {/foreach}
                    
                </dl>
            </div>

            <dl class="fly-panel fly-list-one">
                <dt class="fly-panel-title">本周热议</dt>
                {foreach name='hotList' item='vo'}
                <dd>
                    <a href="{{:url('Card/cardBrowse?id='.$vo.id)}}">{{$vo.name}}</a>
                     <span><i class="iconfont icon-pinglun1"></i> {{$vo.browse}}</span>
                </dd>
                {/foreach}
                <!-- 无数据时 -->
                <!--
                <div class="fly-none">没有相关数据</div>
                -->
            </dl>

            <div class="fly-panel">
                <div class="fly-panel-title">
                    最新推荐
                </div>
                <div class="fly-panel-main">
                    <a href="http://layim.layui.com/" target="_blank" class="fly-zanzhu" time-limit="2017.09.25-2099.01.01" style="background-color: #5FB878;"> layui前端模版制作</a>
                </div>
            </div>

            <div class="fly-panel fly-link">
                <h3 class="fly-panel-title">友情链接</h3>
                <dl class="fly-panel-main">

                    {foreach name='linkList' item='vo'}
                    <dd><a href="{{$vo.lurl}}" target="_blank">{{$vo.lname}}</a><dd>
                    {/foreach}
                
                    <!-- <dd><a href="mailto:xianxin@layui-inc.com?subject=%E7%94%B3%E8%AF%B7Fly%E7%A4%BE%E5%8C%BA%E5%8F%8B%E9%93%BE" class="fly-link">申请友链</a><dd> -->
                </dl>
            </div>

        </div>
    </div>
</div>

<div class="fly-footer">
    <p><a href="#">Fly社区</a> 2018 &copy; <a href="#"></a></p>
    <p>
        <a href="http://www.layui.com/template/fly/" target="_blank">前端框架:Fly社区模版/LAYUI</a>
        <a href="https://github.com/top-think/think" target="_blank">后端框架:TP5</a>
    </p>
</div>

<script>
    $(function(){
        $(".time").each(function(){
            //将时间转化成时间戳
            var time = Date.parse(new Date($(this).text()));
            time = time/ 1000;
            //当前时间
            var newtime = Date.parse(new Date());
            newtime = newtime/ 1000;
            var diff = newtime-time;
//            console.log(newtime);
//            console.log(time);
//            console.log(newtime - time);
            if(diff < 3600){
                $(this).text("刚刚");
            }else if(diff > 3600 && diff <= 86400){ // 1小时 - 5小时
                $(this).text("一小时前");
            }else if(diff > 86400 && diff <= 2592000){ //
                $(this).text("一天前");
            }else if(diff > 2592000 && diff <= 946080000){
                $(this).text("一月前");
            }else if(diff > 946080000){
                $(this).text("一年前");
            }
        })
    })
</script>
{/block}

